<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" media="all" />
	</head>
	<body style="padding: 10px;">
		<form class="layui-form layui-form-pane" action="" lay-filter="formAddCustomer">
			<div class="layui-form-item">
				<label class="layui-form-label">客户</label>
				<div class="layui-input-block">
					<input type="text" name="cusName" placeholder="请输入客户名称" class="layui-input" lay-verify='required'>
				</div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">所在地</label>
			    <div class="layui-input-block">
			      <select name="cusRegion" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">东北</option>
			        <option value="2">西北</option>
			        <option value="3">华北</option>
			        <option value="4">华中</option>
					<option value="5">华南</option>
					<option value="6">西南</option>
					<option value="7">华东</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">销量</label>
			    <div class="layui-input-block">
			      <select name="cusLevel" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">战略合作伙伴</option>
			        <option value="2">合作伙伴</option>
			        <option value="3">大客户</option>
			        <option value="4">重点开发客户</option>
			        <option value="5">普通客户</option>
			        <option value="6">VIP客户</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">等级</label>
			    <div class="layui-input-block">
			      <select name="cusCredit" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">一级</option>
			        <option value="2">二级</option>
			        <option value="3">三级</option>
			        <option value="4">四级</option>
					<option value="5">五级</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">等级</label>
			    <div class="layui-input-block">
			      <select name="cusSatisfaction" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">一级</option>
			        <option value="2">二级</option>
			        <option value="3">三级</option>
			        <option value="4">四级</option>
			        <option value="5">五级</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">网址</label>
				<div class="layui-input-inline">
					<input type="text" name="cusUrl" placeholder="请输入网址" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">客户状态</label>
			    <div class="layui-input-block">
			      <select name="cusState" lay-verify='required'>
			        <option value="">请选择</option>
			        <option value="1">正常</option>
			        <option value="0">不正常</option>
			      </select>
			    </div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitAddCustomer">立即添加</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['form', 'jquery'], function() {
				var form = layui.form;
				var $ = layui.jquery;
				
			 //监听提交
			form.on('submit(submitAddCustomer)', function(d){
				// d.field //表单的数据
				if (form.verify()){
					$.ajax({
						url:'http://localhost:8080/customer/addCustomer',
						type:'POST',  //提交方式，有POST、GET等等
						dataType:'JSON', //后台返回数据格式
						data:d.field, //提交到后台的数据
						success:function(obj){  //执行成功回调函数，返回一个obj对象
							//执行ajax提交成功后处理代码
							layer.msg(obj.msg)
							parent.table.reload('tblCustomer')
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭
						}
					})
				}
			    return false; //阻止form提交刷新
			  });
			})
		</script>
	</body>
</html>
